<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
      <el-form-item label="施工日期" prop="date">
        <el-date-picker v-model="queryParams.date" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                        :style="{width: '100%'}" placeholder="请选择日期" clearable>
        </el-date-picker>
      </el-form-item>
      <el-form-item label="班次" prop="sailings">
        <el-input
          v-model="queryParams.sailings"
          placeholder="请输入班次"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="postList">
      <el-table-column type="index" label="序号" align="center" />
      <el-table-column label="日期" align="center" prop="date" />
      <el-table-column label="所属区队" align="center" prop="taskPlan.parentDeptName" />
      <el-table-column label="班次" align="center" prop="taskPlan.sailings" />
      <el-table-column label="班组" align="center" prop="taskPlan.deptName" />
      <el-table-column label="班组长" align="center" prop="taskPlan.morName" />
      <el-table-column label="验收人" align="center" prop="taskPlan.acceptorName" />
      <el-table-column label="施工地点" align="center" prop="taskPlan.borerLoc" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:post:edit']"
          >查看日报表</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <el-dialog :title="title" :visible.sync="open" width="95%" append-to-body>
      <div class="date">日期:{{d_date}}</div>
      <el-table :data="dailylist">
        <el-table-column label="钻孔编号" align="center" prop="drillInf.borerId" />
        <el-table-column label="施工地点" align="center" prop="drillInf.borerLoc" />
        <el-table-column label="设备型号" align="center" prop="borerInf.borerType" />
        <el-table-column label="施工班次" align="center" prop="taskPlan.sailings" />
        <el-table-column label="方位角" align="center" prop="drillInf.mainAngle" />
        <el-table-column label="倾角" align="center" prop="drillInf.brakeTorque" />
        <el-table-column label="孔深" align="center" prop="drillInf.poreDepth" />
        <el-table-column label="孔径" align="center" prop="drillInf.poreSize" />
        <el-table-column label="计划进尺" align="center" prop="taskPlan.poreDepth" />
        <el-table-column label="当班进尺" align="center" prop="acceptInf.classFootage" />
        <el-table-column label="AI视频计数" align="center" prop="aiInf.countSum" />
        <el-table-column label="验收计数" align="center" prop="acceptInf.acceptCount" />
        <el-table-column label="班组长" align="center" prop="taskPlan.morName" />
        <el-table-column label="钻孔验收情况" align="center" prop="acceptInf.overallOpinion" />
        <el-table-column label="钻孔注浆情况" align="center" prop="acceptInf.groutingCondition" />
        <el-table-column label="视频验收情况" align="center" prop="acceptInf.videoCondition" />
        <el-table-column label="验收人" align="center" prop="taskPlan.acceptorName" />
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="">下 载</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listpost, getpost} from "@/api/system/ys";

export default {
  name: "Ys",
  dicts: ['sys_normal_disable'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 表格数据
      postList: [],
      dailylist: [],
      d_date:undefined,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        sailings: undefined,
        date:undefined
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询岗位列表 */
    getList() {
      this.loading = true;
      listpost(this.queryParams).then(response => {
        this.postList = response.data.taskPlanAddDateDtos;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        postId: undefined,
        postCode: undefined,
        postName: undefined,
        remark: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      if(this.queryParams.date!=undefined){
        var now = new Date(this.queryParams.date);
        var gmtStr = now.toUTCString();
        this.queryParams.date = gmtStr;
      }
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    handleUpdate(row) {
      this.reset();
      const Id = row.date;
      var now = new Date(Id);
      var date = now.toUTCString();
      getpost(date).then(response => {
        this.d_date=Id;
        this.dailylist = response.data;
        this.open = true;
        this.title = "钻孔验收视频日报表";
      });
    },
  }
};
</script>

<style>
  .date{
    font-size: 30px;
  }
</style>
